package io.renren.modules.lucky.controller;

import com.alibaba.fastjson2.JSON;
import io.renren.common.utils.Result;
import io.renren.modules.lucky.dto.background.AddUserReq;
import io.renren.modules.lucky.dto.background.LuckyBillUpdateDto;
import io.renren.modules.lucky.service.LuckyAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/admin")
@Api(tags="招财猫管理员接口")
@AllArgsConstructor
public class LuckyAdminController {
    private static final Logger logger = org.slf4j.LoggerFactory.getLogger(LuckyAdminController.class);

    private final LuckyAdminService luckyAdminService;

    @PostMapping("/addUser")
    @ApiOperation("添加合作商信息")
    public Result report(@RequestBody AddUserReq addUserReq) {
        logger.info("添加合作商信息: {}", JSON.toJSONString(addUserReq));
        Result result = luckyAdminService.addUser(addUserReq);
        logger.info("添加合作商信息返回: {}", JSON.toJSONString(result));
        return result;
    }

    @PostMapping("/updateBill")
    @ApiOperation("更新账单信息")
    public Result updateBill(@RequestBody LuckyBillUpdateDto updateDto) {
        logger.info("更新账单信息: {}", JSON.toJSONString(updateDto));
        Result result = luckyAdminService.updateBill(updateDto);
        logger.info("更新账单信息返回: {}", JSON.toJSONString(result));
        return result;
    }

}
